<template>

  <el-form ref="form" :model="form" label-width="80px" @submit.prevent="createExam">
    <el-form-item style="width: 500px;padding-top: 30px;" for="examName" label="考试名称">
      <el-input id="examName" v-model="exam.name" type="text" required />
    </el-form-item>
    <el-form-item for="examType" label="考试类型">
      <el-select id="examType" v-model="exam.type" placeholder="请选择考试类型">
        <el-option value="test" label="测试" />
        <el-option value="final" label="期末" />
        <el-option value="graduate" label="结业" />
      </el-select>
    </el-form-item>
    <el-form-item style="width: 500px;" for="examTime" label="考试时间">
      <el-col :span="11">
        <input id="examTime" v-model="exam.time" type="datetime-local" required>
      </el-col>
    </el-form-item>
    <el-form-item for="subject" label="考试科目">
      <el-radio-group v-model="radio">
        <el-radio :label="1">英语</el-radio>
        <el-radio :label="2">数学</el-radio>
        <el-radio :label="3">专业</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item>
      <el-button type="submit" @click="onSubmit">立即创建</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      exam: {
        name: '',
        type: '',
        time: '',
        questionType: '',
        subject: ''
      },
      form: {
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      }
    }
  },
  methods: {
    async createExam() {
      try {
        const response = await this.$axios.post('/api/exams', this.exam)
        // 处理响应
        alert('考试创建成功！')
        console.log(response.data)
      } catch (error) {
        // 处理错误
        alert('创建考试失败，请重试！')
        console.error('Error:', error)
      }
    },
    onSubmit() {
      this.$message('submit!')
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

